Example #1
0
    def test_delete_other_anonymous_user(self):
        self._create_session('a-key')
        self._create_workflow('Workflow', session_key='another-key')

        delete_expired_anonymous_workflows()

        self.assertEqual(Workflow.objects.count(), 0)
Example #2
0
    def test_preserve_owner(self):
        owner = self._create_user('Alice')
        self._create_workflow('Workflow', owner=owner)

        delete_expired_anonymous_workflows()

        self.assertEqual(Workflow.objects.count(), 1)
Example #3
0
    def test_delete_other_anonymous_user(self):
        self._create_session('a-key')
        self._create_workflow('Workflow', session_key='another-key')

        with self.assertLogs(maintenance.__name__):
            delete_expired_anonymous_workflows()

        self.assertEqual(Workflow.objects.count(), 0)
Example #4
0
    def test_preserve_owner(self):
        owner = self._create_user('Alice')
        self._create_workflow('Workflow', owner=owner)

        with self.assertLogs(maintenance.__name__):
            delete_expired_anonymous_workflows()

        self.assertEqual(Workflow.objects.count(), 1)
Example #5
0
    def handle(self, *args, **options):
        while True:
            time1 = time.time()

            try:
                update_wfm_data_scan()
            except Exception as err:
                _logger.exception(err)

            try:
                delete_expired_anonymous_workflows()
            except Exception as err:
                _logger.exception(err)

            time2 = time.time()
            duration = time2 - time1
            delay = max(0, _MaxDelay - duration)
            time.sleep(delay)
Example #6
0
async def main():
    async with PgLocker() as pg_locker:
        while True:
            time1 = time.time()

            try:
                await update_wfm_data_scan(pg_locker)
            except Exception as err:
                _logger.exception(err)

            try:
                delete_expired_anonymous_workflows()
            except Exception as err:
                _logger.exception(err)

            time2 = time.time()
            duration = time2 - time1
            delay = max(0, _MaxDelay - duration)
            await asyncio.sleep(delay)
Example #7
0
 def handle(self, *args, **options):
     maintenance.delete_expired_anonymous_workflows()