# Using PythonKit in multi-threaded application

**URL:** <https://forums.swift.org/t/using-pythonkit-in-multi-threaded-application/55155>\
**Category:** Using Swift\
**Tags:** pythonkit\
**Created:** [February 7, 2022, 2:59pm UTC](https://forums.swift.org/t/using-pythonkit-in-multi-threaded-application/55155 "2022-02-07T14:59:47Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![willon](https://avatars.discourse-cdn.com/v4/letter/w/e9bcb4/32.png) [@willon](https://forums.swift.org/u/willon)\
**Post date:** [November 22, 2023, 1:44pm UTC](https://forums.swift.org/t/using-pythonkit-in-multi-threaded-application/55155/11 "2023-11-22T13:44:07Z")

</div>

I got the same error. And I think pythonkit don't support subthread, because I really create a serial thread for it. Here is my code :

```swift

    lazy var thread:Thread = {
        var t = Thread(target: self, selector: #selector(begin), object: nil)
        t.name = "com.python"
        t.qualityOfService = .default // i tested all of qos enum, but all of them not work
        return t
    }()

.....

    @objc
    func begin() {
        print("pre start")
        let example = Python.import("my_python_module")
        print("start")
        let result = example.start()
        print(result)
    }

```

PS: I'm already call self.thread.start() to run the thread.

It's always \_pthread\_cond\_wait () for something

 ![WX20231122-214220@2x](https://global.discourse-cdn.com/swift/original/3X/5/7/573d85cfee6ffb36a8c2c47405236ec3a627b512.jpeg)

---

_[View the full topic](https://forums.swift.org/t/using-pythonkit-in-multi-threaded-application/55155)._
