class Abstract(QtGui.QWidget):passclass Imp(QtGui.QLineEdit, Abstract):def __init__(self):QtGui.QLineEdit.__init__(self)# Abstract.__init__(self) # <-- not legal# RuntimeError: You can't initialize an object twice!
TypeError: Error when calling the metaclass basesmetaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBL_NwPBZrMhf12FEROVPnBV_8%2B8fAqyZ2OKXqsTabujw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/78B20000-CC99-4A5F-9059-A287D7B0419E%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
This includes any use of QThread and the Python threading module."
Can you expand on where this information comes from? What kind of crashes have you experienced, that you attribute them to the use of Signals and QThreads/Threads?
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBssq4RmHN7iVYwrRJHUtUDkhKisqo1n3guUpefL34NVQ%40mail.gmail.com.
Interesting article. I liked the part where you point out that various concepts in PyQt/PySide really just stem from the needs in the C++ world, but don't always carry the same relevance in python (QString, QVariant, ...). C++ had to do a lot more work to add the "dynamic" characteristics it provides (introspection and whatnot).
Although, I did feel it was a bit light around the subject of what the pyqtSignal() is, and what (reading why) you can't assign a fresh instance in your constructor.
Can you expand on where this information comes from? What kind of crashes have you experienced, that you attribute them to the use of Signals and QThreads/Threads?
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA23kWOA94QusaoT2Hh8vaqBkG3rH%3DyZmYyK8%3DjK_2yjVg%40mail.gmail.com.
Hey Justin, thanks for your feedback. :)Interesting article. I liked the part where you point out that various concepts in PyQt/PySide really just stem from the needs in the C++ world, but don't always carry the same relevance in python (QString, QVariant, ...). C++ had to do a lot more work to add the "dynamic" characteristics it provides (introspection and whatnot).Glad you liked it. Perhaps I should add the bit about differences between API version 1 and 2 of QString too; that was a hurdle for me in the beginning (particularly its use in modelviews) and I'm sure there are more instances of problems like that throughout PyQt because, like you say, C++ being slightly different.Although, I did feel it was a bit light around the subject of what the pyqtSignal() is, and what (reading why) you can't assign a fresh instance in your constructor.The article really is more about the class at the top, than it is about pyqtSignal, but you're right, I wish I knew more about it than I do. The docs aren't very in-depth about this and after glancing over the PyQt source (source\qpy\QtCore\qpycore_pyqtsignal.h) I quickly decided it was over my head and decided to go for perceived experiences on this one.Can you expand on where this information comes from? What kind of crashes have you experienced, that you attribute them to the use of Signals and QThreads/Threads?
Hm, it worries me that you ask. I can safely say that I've had threads crash with Signal that does work with pyqtSignal when signal is returning data, but I'm fairly new in regards to threading and my main source of attributing crashes with data exchange over threads comes from here (as the class contains no thread synchronisation or locking of resources). I would love to hear about your experiences in this area!
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODi9dCtdZUDc_Bc39ysKZiPPvEy4mBnOEd7%2BmF1nxguaQ%40mail.gmail.com.
import time
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
class Window(QWidget):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.__thread = None
self.button = QPushButton('Push me')
self.result = QLineEdit()
self.result.setObjectName('ResultWidget')
layout = QBoxLayout(QBoxLayout.TopToBottom, self)
layout.addWidget(self.button)
layout.addWidget(self.result)
self.button.pressed.connect(self.compute_result)
def compute_result(self):
if self.__thread:
self.__thread.exit()
self.__thread = None
class CascadingThread(QThread):
done = pyqtSignal(str) # Emitted when finished
# done = Signal()
def run(self):
time.sleep(2) # Pretend it takes quite a while
self.done.emit('Here is the result')
self.__thread = CascadingThread(self) # Delegate computation to another thread
self.__thread.done.connect(self.computed_event)
self.__thread.start()
self.button.setEnabled(False)
self.result.setText('Computing...')
def computed_event(self, result):
self.result.setText(result)
self.button.setEnabled(True)
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
win = Window()
win.show()
sys.exit(app.exec_())
Best,Marcus
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBL_NwPBZrMhf12FEROVPnBV_8%2B8fAqyZ2OKXqsTabujw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/78B20000-CC99-4A5F-9059-A287D7B0419E%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBssq4RmHN7iVYwrRJHUtUDkhKisqo1n3guUpefL34NVQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA23kWOA94QusaoT2Hh8vaqBkG3rH%3DyZmYyK8%3DjK_2yjVg%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
That is some rather naive use of threads you're implying :) but you may be right.
Trying to recreate the issue in a minimal snippet failed, but I'll post it here anyway and return once I encounter it again.Just so I understand you correctly, you've successfully sent data between threads, without the use of pyqtSignal or using your own signal implementation, and not encountered any issues? That would be delightful, as I'm researching how to deal with thread-safety at the moment due to this exact issue. But maybe I won't have to!
The issue at hand relates to delegating computations to separate threads so as to increase the interactivity for users clicking about in a gui, so threads are run as users interact, with data being sent to and from the ui.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/aafbc954-9049-4a6f-a631-f81cee7b9394%40googlegroups.com.
(just butting into an interesting conversation)Justin Wrote:“Although if there is some concrete evidence that it is a known issue,then you would be correct”
Ah!, but keep in mind that most known issues have known workarounds, a frequent crash can easily be unknown and never fully examined, often analysed from the wrong end even causing even more complications. As in just because it’s not apparent in standard behaviour it does not make either party right or wrong.Just because there is no evidence to examine definitely does not equal the person observing it being wrong in any way.
If it helps, you can try to produce a crash using QTimer inside a QThread, that one is on my dirty list of “how on earth does that crash so often” without myself ever having been able to attribute the cause to either a threading issue or anything known that went wrong for the person who wrote it.In my experience most of these cases turn out to be an OS problem rather than anything related to the scripting part of the process so I have to agree with both you guys on this one; It does crash a lot but indeed far from it being a known issue so it presumably doesn’t belong as the blanket statement it reads as.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/52ded548.270ac20a.122d.fffff19c%40mx.google.com.
I think maybe I misunderstood you previously. I thought we *were* talking about using signals to pass data between threads? But you are asking if I have done it without signals?
import threading
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
PORT = 18000
class CustomSignal:
def __init__(self):
self.__subscribers = []
def emit(self, *args, **kwargs):
for subs in self.__subscribers:
subs(*args, **kwargs)
def connect(self, func):
self.__subscribers.append(func)
def disconnect(self, func):
try:
self.__subscribers.remove(func)
except ValueError:
print('Warning: function %s not removed '
'from signal %s'%(func,self))
class Window(QWidget):
rpc_show = pyqtSignal() # Causes no crash
# rpc_show = CustomSignal() # Causes crash
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.__rpc_server = None
self.rpc_show.connect(self.restore)
def start_rpc(self):
from rpyc.utils.server import ThreadedServer
from rpyc.core import SlaveService
if self.__rpc_server:
self.__rpc_server.close()
self.__rpc_server = None
class Service(SlaveService):
def exposed_show(self):
self.show_signal.emit()
Service.show_signal = self.rpc_show
server = ThreadedServer(Service, port=PORT, reuse_addr=True)
self.__rpc_server = server
def thread():
self.__rpc_server.start()
print("Running RPC server")
thread = threading.Thread(target=thread, name="rpc")
thread.daemon = True
thread.start()
def restore(self):
self.activateWindow()
self.showNormal()
def start_application():
import sys
app = QApplication(sys.argv)
win = Window()
win.show()
win.start_rpc()
sys.exit(app.exec_())
def request_application():
print("Requesting a new Window")
import socket
import rpyc
try:
proxy = rpyc.connect('localhost', PORT)
proxy.root.show()
print("Restored existing instance of Window")
except socket.error:
print("Running new instance of Window")
start_application()
if __name__ == '__main__':
request_application()--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/95bdc1ec-09cd-4086-baee-21715533db5b%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3%2B_t_FCEOnpLD8k_XMYk1GawfzKuKsQUgmC59y-34SXA%40mail.gmail.com.