import xbmc
import urllib2
import threading
from pulsar.config import PULSARD_HOST


class PulsarMonitor(xbmc.Monitor):
    def __init__(self):
        self._closing = threading.Event()

    @property
    def closing(self):
        return self._closing

    def onAbortRequested(self):
        self._closing.set()

    def onSettingsChanged(self):
        try:
            urllib2.urlopen("%s/reload" % PULSARD_HOST)
        except:
            pass

import xbmc
import urllib2
import threading
from pulsar.config import PULSARD_HOST


class PulsarMonitor(xbmc.Monitor):
    def __init__(self):
        self._closing = threading.Event()

    @property
    def closing(self):
        return self._closing

    def onAbortRequested(self):
        # Only when closing Kodi
        if xbmc.abortRequested:
            self._closing.set()
            self._closing.clear()

    def onSettingsChanged(self):
        try:
            urllib2.urlopen("%s/reload" % PULSARD_HOST)
        except:
            pass

Fix issue where Pulsar would enter a restart loop when cancelling a buffering
Fix issue where Pulsar would enter a restart loop when cancelling a buffering

Signed-off-by: Steeve Morin <7f3ba7bbc079b62d3fe54555c2b0ce0ddda2bb7c@gmail.com>

  import xbmc
  import urllib2
  import threading
  from pulsar.config import PULSARD_HOST
  
  
  class PulsarMonitor(xbmc.Monitor):
      def __init__(self):
          self._closing = threading.Event()
  
      @property
      def closing(self):
          return self._closing
  
      def onAbortRequested(self):
+         # Only when closing Kodi
+         if xbmc.abortRequested:
-         self._closing.set()
+             self._closing.set()
+             self._closing.clear()
  
      def onSettingsChanged(self):
          try:
              urllib2.urlopen("%s/reload" % PULSARD_HOST)
          except:
              pass
  
Fix issue where Pulsar would enter a restart loop when cancelling a buffering
## Code Before:
import xbmc
import urllib2
import threading
from pulsar.config import PULSARD_HOST


class PulsarMonitor(xbmc.Monitor):
    def __init__(self):
        self._closing = threading.Event()

    @property
    def closing(self):
        return self._closing

    def onAbortRequested(self):
        self._closing.set()

    def onSettingsChanged(self):
        try:
            urllib2.urlopen("%s/reload" % PULSARD_HOST)
        except:
            pass

## Instruction:
Fix issue where Pulsar would enter a restart loop when cancelling a buffering
## Code After:
import xbmc
import urllib2
import threading
from pulsar.config import PULSARD_HOST


class PulsarMonitor(xbmc.Monitor):
    def __init__(self):
        self._closing = threading.Event()

    @property
    def closing(self):
        return self._closing

    def onAbortRequested(self):
        # Only when closing Kodi
        if xbmc.abortRequested:
            self._closing.set()
            self._closing.clear()

    def onSettingsChanged(self):
        try:
            urllib2.urlopen("%s/reload" % PULSARD_HOST)
        except:
            pass
