# Using Worker Service

**URL:** https://discuss.tryton.org/t/using-worker-service/8751
**Category:** Developer
**Created:** [July 31, 2025, 5:45pm UTC](https://discuss.tryton.org/t/using-worker-service/8751 "2025-07-31T17:45:19Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![bromoapp](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bromoapp](https://discuss.tryton.org/u/bromoapp)
#### Post date: [July 31, 2025, 5:45pm UTC](https://discuss.tryton.org/t/using-worker-service/8751/1 "2025-07-31T17:45:19Z")

</div>

Hi,

Hi,

I would like to use **Worker Service** mentioned [here](https://docs.tryton.org/latest/server/topics/start_server.html#worker-service),

And I found [this](https://discuss.tryton.org/t/how-to-configure-correctly-queues/6944) article on how to set worker in **trytond.conf** file

My current **trytond.conf** is like below:

```auto
[web]
listen = domain:port
root = /somedir/www/
[database]
uri = postgresql://dbuser:secret@something:port/dbname
[queue]
worker = True

```

Can anybody show me how to utilize this from any python class programmatically?  
A link to a git code would be appreciated too.

Regards  
Bromo

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [July 31, 2025, 9:44pm UTC](https://discuss.tryton.org/t/using-worker-service/8751/2 "2025-07-31T21:44:01Z")

</div>

Submitting task to the queue is explained in [Task Queue — Tryton server](https://docs.tryton.org/latest/server/topics/task_queue.html#task-queue)

---

<div class="post-metadata">

### Author: ![bromoapp](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bromoapp](https://discuss.tryton.org/u/bromoapp)
#### Post date: [August 4, 2025, 3:26pm UTC](https://discuss.tryton.org/t/using-worker-service/8751/3 "2025-08-04T15:26:45Z")

</div>

This is what I did:

```auto
    @classmethod
    def write(cls, records, values, *args):
        result = super().write(records, values, *args)
        cls.launch(0)
        return result

    @classmethod
    def launch(cls, records):
        cls. __queue__.process(records)

    def process(self, values):
        logger.info(">>"*50)
        logger.info(">>>>>>>>>>>>>>>>>>>> PROCESS RUNNING...")

```

I put a call to **cls.launch(0)** from inside write method, but when I executed update data that triggers **write** method.. the **process(self, values)** doesn’t run.. where am I missing?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 4, 2025, 5:10pm UTC](https://discuss.tryton.org/t/using-worker-service/8751/4 "2025-08-04T17:10:53Z")

</div>

You need to have a worker running.

---

<div class="post-metadata">

### Author: ![bromoapp](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bromoapp](https://discuss.tryton.org/u/bromoapp)
#### Post date: [August 5, 2025, 4:23am UTC](https://discuss.tryton.org/t/using-worker-service/8751/6 "2025-08-05T04:23:03Z")

</div>

Hi, may I know how to turn on a worker? … I really thought that the config enough, sorry for this rookie question.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 5, 2025, 5:29am UTC](https://discuss.tryton.org/t/using-worker-service/8751/7 "2025-08-05T05:29:32Z")

</div>

See [How to start the server — Tryton server](https://docs.tryton.org/latest/server/topics/start_server.html#worker-service)

---

<div class="post-metadata">

### Author: ![bromoapp](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bromoapp](https://discuss.tryton.org/u/bromoapp)
#### Post date: [August 6, 2025, 4:39am UTC](https://discuss.tryton.org/t/using-worker-service/8751/8 "2025-08-06T04:39:39Z")

</div>

Ok what I did:

In **trytond.conf** file:

```auto
[web]
listen = localhost:8000
root = /var/www/
[database]
uri = postgresql://tryton:secret@localhost:5432/tryton
[queue]
worker = True

```

In python class:

```auto
    @classmethod
    def write(cls, records, values, *args):
		#--- a lot of code -----
		
        cls. __queue__.process(list([1]))
        return result

    def process(cls):
        logger.info(f">>>>>>>>>>>>>>>>>>>>>>>>> EXECUTING PROCESS")
        #--- perform database operations ---

```

In command line:

```auto
trytond -c trytond.conf --logconf logging.conf
trytond-worker -c trytond.conf -d tryton --logconf logging.conf

```

I did all of the above.. but still the database operations codes inside **process** method not executed

Where else I missed?

Bromo

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 6, 2025, 5:48am UTC](https://discuss.tryton.org/t/using-worker-service/8751/9 "2025-08-06T05:48:05Z")

</div>

Do you find your job in the `ir_queue` table? What are the values?

---

<div class="post-metadata">

### Author: ![bromoapp](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bromoapp](https://discuss.tryton.org/u/bromoapp)
#### Post date: [August 6, 2025, 8:28am UTC](https://discuss.tryton.org/t/using-worker-service/8751/10 "2025-08-06T08:28:23Z")

</div>

![image](https://discuss-cdn.tryton.org/uploads/default/original/2X/1/1a0d69586ca992f1f80b880cf73fe853cc6f10df.png)

This is the content of **ir.queue** table.. yes it is correct that the worker is running.. but it doesn’t perform the database operation that is inside the **process** method.

The real code inside def process(cls) method is like below:

```auto
def process(cls):
    logger.info(f">>>>>>>>>>>>>>>>>>>>>>>>> EXECUTING PROCESS")
    pool = Pool()
    ProjectAllocation = pool.get('afx.project.allocation')
    ProjectAllocation.update_project_allocation_records()
    

```

The method of **ProjectAllocation.update\_project\_allocation\_records()** is not executed.  
The initial reason is: I want **ProjectAllocation.update\_project\_allocation\_records()** executed async and non blocking.. because the execution of it takes more than 30 seconds.. and I am hoping by doing this async via Task Queue.. I can execute it on different thread.

Or am I doing it wrongly?

Bromo

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 6, 2025, 8:37am UTC](https://discuss.tryton.org/t/using-worker-service/8751/11 "2025-08-06T08:37:31Z")

</div>

I guess there should be a traceback in the log of the worker because you put a call for process with a list of id but the process method does not accept arguments.

---

<div class="post-metadata">

### Author: ![bromoapp](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/71c47a/32.png) [@bromoapp](https://discuss.tryton.org/u/bromoapp)
#### Post date: [August 6, 2025, 10:51am UTC](https://discuss.tryton.org/t/using-worker-service/8751/12 "2025-08-06T10:51:49Z")

</div>

Okay, I changed the **process** method and add **arguments** as below:

```auto
    @classmethod
    def write(cls, records, values, *args):
		#--- a lot of code -----
		
        cls. __queue__.process(list([1]))
        return result

    def process(cls, values):
        logger.info(f">>>>>>>>>>>>>>>>>>>>>>>>> EXECUTING PROCESS {values}")
        pool = Pool()

        #--- Below method call are the most important thing
        #--- because the whole idea of using this queue is to
        #--- delegate the execution of below class methods
        #--- outside the main thread

        ProjectAllocation = pool.get('afx.project.allocation')
        ProjectAllocation.update_project_allocation_records()

```

and now the record in **ir.queue** become like below:

```auto
{"args": [], "user": 1, "model": "afx.project", "kwargs": {}, "method": "process",
 "context": {"client": "863512e1-9e70-4d99-889b-d578e191d62d", 
"groups": [1, 772, 773, 774, 701, 702, 466, 464, 467, 703, 704, 472, 465, 
468, 469, 778, 470, 471], "company": 1, "_request": {"scheme": "http", 
"http_host": "localhost:8000", "is_secure": false, "remote_addr": "127.0.0.1"},
 "employee": 1, "company_filter": "one", "click_my_projects": "1", 
"company_work_time": {"M": 576000, "Y": 6912000, "d": 28800, "h": 3600, "m": 60,
 "s": 1, "w": 144000}, "language_direction": "ltr"}, "instances": [1]}

```

But event thou this **process** method may be called via **Queue** … the codes within the **process** method aren’t executed, which is the most important thing.

Bromo

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [August 6, 2025, 11:55am UTC](https://discuss.tryton.org/t/using-worker-service/8751/13 "2025-08-06T11:55:21Z")

</div>

I kind of deduce that the jobs are correctly dequeued because it seems from the screenshot that the column has been filled.  
So I suspect that it is working but just that you do not look at the right thing.
