# Async tasks

**URL:** https://discourse.paraview.org/t/async-tasks/3571
**Category:** ParaView Support
**Tags:** python, vtk
**Created:** [February 14, 2020, 11:37pm UTC](https://discourse.paraview.org/t/async-tasks/3571 "2020-02-14T23:37:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sohayb\_bahi](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sohayb_bahi/32/2846_2.png) [@sohayb\_bahi](https://discourse.paraview.org/u/sohayb_bahi)
#### Post date: [February 14, 2020, 11:37pm UTC](https://discourse.paraview.org/t/async-tasks/3571/1 "2020-02-14T23:37:07Z")

</div>

Hi ,

I have a python script that uses vtk to launch a vtk window to visualize an object . This window is created and launched by a function and this function is assigned to a thread . I’m launching another function that will take information from the camera i the vtk window and write it to a text file. This function is also assigned to another thread . From the main() i’m trying to launch the two threads in parallel. The problem is that when i launch the vtk window function in a thread and then launch the other function in another thread , the vtk thread blocks everything (in the sense that code after this doesn’t run) and when i close the vtk window the code after it continues.

When testing different things i discovered that this function blocks everything :  
—renderWindowInteractor.Start()

Have you got a solution for that ??

---

<div class="post-metadata">

### Author: ![randomwangran](https://discourse.paraview.org/user_avatar/discourse.paraview.org/randomwangran/32/5929_2.png) [@randomwangran](https://discourse.paraview.org/u/randomwangran)
#### Post date: [February 20, 2020, 3:19pm UTC](https://discourse.paraview.org/t/async-tasks/3571/3 "2020-02-20T15:19:09Z")

</div>

Please clarify what you want to achieve.

You want to do async tasks?

You can do this by launching ParaView from \*.pvsm.

---

<div class="post-metadata">

### Author: ![sohayb\_bahi](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sohayb_bahi/32/2846_2.png) [@sohayb\_bahi](https://discourse.paraview.org/u/sohayb_bahi)
#### Post date: [February 21, 2020, 3:45pm UTC](https://discourse.paraview.org/t/async-tasks/3571/4 "2020-02-21T15:45:15Z")

</div>

I’ve found a solution but i don’t know how to implement it.  
I found this funtion : renderWindowInteractor.AddObserver(‘TimerEvent’, CallBack.writer)

With this observer i can catch different events .This example works fine when i launch from pyCharm with vtk because it creates a Window that i can interact with. The code i’m talking about is this:

```
    renderWindowInteractor.Initialize()
    cb = ReaderWriterCallback()
    cb.actor = actor
    renderWindowInteractor.AddObserver('TimerEvent', cb.writer)
    timerId = renderWindowInteractor.CreateRepeatingTimer(100)

    # start the interaction and timer
    renderWindowInteractor.Start() 

```

As you see in this example , the Event is Timer , but the problem is that when i try to  
launch the

```
 renderWindowInteractor.CreateRepeatingTimer(100)

```

on paraview , it doesn’t recognize because it’s not a paraview function . In other words i want to interact with the paraview Render View on paraview and not vtk GUI. For example i would like to detect MouseEvents in paraview but it doesn’t work .
