# Path: pq/utils/concurrency.py
# ASYNC_IO = 1        # run in the worker event loop
# THREAD_IO = 3       # run in the event loop executor
# CPUBOUND = 4        # run in a subprocess


import sys
import logging
import inspect
import asyncio
from datetime import datetime, date
from pulsar.utils.slugify import slugify
from pulsar.utils.importer import import_modules
from pulsar.utils.log import lazyproperty
from pulsar.utils.string import to_bytes
from ..utils.concurrency import concurrency_name, ASYNC_IO




class ShellError(RuntimeError):

    @property
    def returncode(self):
        return self.args[1] if len(self.args) > 1 else 1


class RegistryMixin:

    @lazyproperty
    def registry(self):
        '''The :class:`.JobRegistry` for this backend.
        '''
        return JobRegistry.load(self.cfg.task_paths)

    def job_list(self, jobnames=None):
        registry = self.registry
        jobnames = jobnames or registry
        all = []
        for name in jobnames:
            if name not in registry:
                continue
            job = registry[name]()
            d = {'doc': job.__doc__,
                 'doc_syntax': job.doc_syntax,

# Path: pq/utils/concurrency.py
# ASYNC_IO = 1        # run in the worker event loop
# THREAD_IO = 3       # run in the event loop executor
# CPUBOUND = 4        # run in a subprocess


# Path: pq/tasks/models.py
import sys
import logging
import inspect
import asyncio
from datetime import datetime, date
from pulsar.utils.slugify import slugify
from pulsar.utils.importer import import_modules
from pulsar.utils.log import lazyproperty
from pulsar.utils.string import to_bytes
from ..utils.concurrency import concurrency_name, ASYNC_IO





class ShellError(RuntimeError):

    @property
    def returncode(self):
        return self.args[1] if len(self.args) > 1 else 1


class RegistryMixin:

    @lazyproperty
    def registry(self):
        '''The :class:`.JobRegistry` for this backend.
        '''
        return JobRegistry.load(self.cfg.task_paths)

    def job_list(self, jobnames=None):
        registry = self.registry
        jobnames = jobnames or registry
        all = []
        for name in jobnames:
            if name not in registry:
                continue
            job = registry[name]()
            d = {'doc': job.__doc__,
                 'doc_syntax': job.doc_syntax,

                 'concurrency': concurrency_name.get(job.concurrency),