import datetime
import typing as T

import requests
from PyQt5 import QtCore

from panel.updaters.base import BaseUpdater
from panel.util import exception_guard


class CurrencyUpdater(BaseUpdater):
    quotes_changed = QtCore.pyqtSignal()

    def __init__(self) -> None:
        super().__init__()
        timer = QtCore.QTimer(self)
        timer.setInterval(60000)
        timer.timeout.connect(self._on_timeout)
        timer.start()

        self.quotes: T.Dict[datetime.datetime, float] = {}
        self._on_timeout()

    def _on_timeout(self) -> None:
        with exception_guard():
            response = requests.get(
                "https://www.ingturbo.pl/services/underlying/usd-pln/chart"
                "?period=intraday"
            )
            response.raise_for_status()

            for row in response.json()["Quotes"]:
                time, quote = row
                date = datetime.datetime.fromtimestamp(time / 1000.0)
                self.quotes[date] = quote

            self.quotes_changed.emit()

@@ -9,16 +9,28 @@
 atetime%0A
+import time%0A
 import t
@@ -193,39 +193,41 @@
 ater
-(BaseUpdater):%0A    quotes_chang
+Thread(QtCore.QThread):%0A    updat
 ed =
@@ -245,16 +245,22 @@
 tSignal(
+object
 )%0A%0A    d
@@ -271,24 +271,48 @@
 _init__(self
+, parent: QtCore.QObject
 ) -%3E None:%0A 
@@ -339,149 +339,44 @@
 t__(
-)%0A        timer = QtCore.QTimer(self)%0A        timer.setInterval(60000)%0A        timer.timeout.connect(self._on_timeout)%0A        timer.start()%0A
+parent)%0A        self.running = False
 %0A   
@@ -435,101 +435,90 @@
  %7B%7D%0A
+%0A
     
-    self._on_timeout()%0A%0A    def _on_timeout(self) -%3E None:%0A        with exception_guard()
+def run(self) -%3E None:%0A        self.running = True%0A        while self.running
 :%0A  
@@ -784,16 +784,17 @@
         
+_
 time, qu
@@ -858,16 +858,17 @@
 mestamp(
+_
 time / 1
@@ -938,26 +938,382 @@
 elf.
-quotes_changed.emi
+updated.emit(self.quotes)%0A            time.sleep(60)%0A%0A%0Aclass CurrencyUpdater(BaseUpdater):%0A    quotes_changed = QtCore.pyqtSignal()%0A%0A    def __init__(self) -%3E None:%0A        super().__init__()%0A%0A        self._thread = CurrencyUpdaterThread(self)%0A        self._thread.updated.connect(self.quotes_changed.emit)%0A        self.quotes = self._thread.quotes%0A        self._thread.star
 t()%0A

change to use threads