From 383a074d3273214093cbae0c5cdcf6887b1432c3 Mon Sep 17 00:00:00 2001
From: David Trattnig <david.trattnig@o94.at>
Date: Wed, 10 Jun 2020 11:11:18 +0200
Subject: [PATCH] Avoid hybrid property due threading issues.

---
 modules/core/engine.py    | 14 +++++++-------
 modules/database/model.py |  5 ++---
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/modules/core/engine.py b/modules/core/engine.py
index 4f9e9f67..a946cf3e 100644
--- a/modules/core/engine.py
+++ b/modules/core/engine.py
@@ -245,19 +245,19 @@ class SoundSystem():
         is_ready = False
 
         # LIVE
-        if entry.type == ChannelType.LIVE:
+        if entry.get_type() == ChannelType.LIVE:
             entry.channel = "linein_" + entry.source.split("line://")[1]
             is_ready = True
         else:
             # Choose and save the input channel
-            entry.previous_channel, entry.channel = self.channel_swap(entry.type)
+            entry.previous_channel, entry.channel = self.channel_swap(entry.get_type())
 
         # PLAYLIST
-        if entry.type == ChannelType.FILESYSTEM:
+        if entry.get_type() == ChannelType.FILESYSTEM:
             is_ready = self.playlist_push(entry.channel, entry.source)
             
         # STREAM
-        elif entry.type == ChannelType.HTTP or entry.type == ChannelType.HTTPS:
+        elif entry.get_type() == ChannelType.HTTP or entry.get_type() == ChannelType.HTTPS:
             is_ready = self.stream_load_entry(entry)
 
         if is_ready == True:
@@ -286,11 +286,11 @@ class SoundSystem():
 
         # Validate entry type
         for entry in entries:
-            if entry.type != ChannelType.FILESYSTEM:
+            if entry.get_type() != ChannelType.FILESYSTEM:
                 raise InvalidChannelException
         
         # Determine channel
-        channel = self.channel_swap(entry.type)
+        channel = self.channel_swap(entry.get_type())
 
         # Queue entries
         for entry in entries:
@@ -336,7 +336,7 @@ class SoundSystem():
             self.disable_transaction()
 
             # Update active channel and type
-            self.active_channel[entry.type] = entry.channel     
+            self.active_channel[entry.get_type()] = entry.channel     
 
             # Dear filesystem channels, please leave the room as you would like to find it!
             if entry.previous_channel and entry.previous_channel in ChannelType.FILESYSTEM.channels:
diff --git a/modules/database/model.py b/modules/database/model.py
index a3a9a31b..ca2504b3 100644
--- a/modules/database/model.py
+++ b/modules/database/model.py
@@ -247,7 +247,7 @@ class Schedule(DB.Model, AuraDatabaseModel):
 
             "show": {
                 "name": self.show_name,
-                "type": self.type,
+                "type": self.get_type(),
                 "host": self.show_hosts
             },
 
@@ -451,8 +451,7 @@ class PlaylistEntry(DB.Model, AuraDatabaseModel):
     def volume(self):
         return 100 # FIXME Make DB Column
 
-    @hybrid_property
-    def type(self):
+    def get_type(self):
         return EngineUtil.get_channel_type(self.uri)
 
 
-- 
GitLab