How to set project variables inside process running on Thread?

Registered Posts: 2 ✭✭

Hi there,

I am trying to set some project variable using set_variable() method of Dataiku API. But it somehow only runs once. Below is my DASH webapp code snippet for reference -

import threading
import dataiku
import time

def start_execution_publish_to_pbi(config_id):
try:
project = dataiku.Project()
variables = project.get_variables()
variables['standard']['projection_publish_to_pbi_running_process'] = config_id
project.set_variables(variables)

time.sleep(10)


project = dataiku.Project() #Does not update the project variable
variables = project.get_variables()
variables['standard']['projection_publish_to_pbi_running_process'] = ''
project.set_variables(variables)
except Exception as e:

project = dataiku.Project()
variables = project.get_variables()
variables['standard']['projection_publish_to_pbi_running_process'] = ''
project.set_variables(variables) thread = threading.Thread(target=start_execution_publish_to_pbi, args=('101',))
thread.daemon = True # To ensure threads don't block app shutdown
thread.start()

Can some one please assist here why the set_variable() does not works second time?

P.S. - I am trying to implement a task queue which will not trigger the start_execution_publish_to_pbi() if there is already some process running.

Operating system used: Windows

Operating system used: Windows

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.