How to use Pygame in a seperate thread on Linux, Mac and Windowspyagme screen not working with multithreadingHow should I unit test threaded code?How do I update the GUI from another thread?How to use threading in Python?How to check if running in Cygwin, Mac or Linux?How do I install pip on Windows?How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor?Pygame Multithreadingpygame.error: File is not a Windows BMP fileDraw shape given x and y coordinates pygameRender numpy array on screen in pygame

What is the meaning of "You've never met a graph you didn't like?"

What does "Scientists rise up against statistical significance" mean? (Comment in Nature)

Did I make a mistake by ccing email to boss to others?

Why does the Persian emissary display a string of crowned skulls?

Is there anyway, I can have two passwords for my wi-fi

Unable to disable Microsoft Store in domain environment

Overlapping circles covering polygon

In One Punch Man, is King actually weak?

Would a primitive species be able to learn English from reading books alone?

Why do Radio Buttons not fill the entire outer circle?

How to test the sharpness of a knife?

What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?

Do I have to know the General Relativity theory to understand the concept of inertial frame?

Sigmoid with a slope but no asymptotes?

Do you waste sorcery points if you try to apply metamagic to a spell from a scroll but fail to cast it?

How do you justify more code being written by following clean code practices?

How to write Quadratic equation with negative coefficient

When and why was runway 07/25 at Kai Tak removed?

How do I tell my boss that I'm quitting in 15 days (a colleague left this week)

Pre-Employment Background Check With Consent For Future Checks

Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?

What should be the ideal length of sentences in a blog post for ease of reading?

Is there a RAID 0 Equivalent for RAM?

Grepping string, but include all non-blank lines following each grep match



How to use Pygame in a seperate thread on Linux, Mac and Windows


pyagme screen not working with multithreadingHow should I unit test threaded code?How do I update the GUI from another thread?How to use threading in Python?How to check if running in Cygwin, Mac or Linux?How do I install pip on Windows?How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor?Pygame Multithreadingpygame.error: File is not a Windows BMP fileDraw shape given x and y coordinates pygameRender numpy array on screen in pygame













0















I'm developing a screen share application and I am using a thread for receiving the data from a socket.io server, and a thread for displaying it. It works perfectly well, as long as I run it under a Linux platform.



I've tried it on my Mac, but after doing some research apparently macOS doesnt allow you to draw to threads other than the main thread, and i need it to work on all platforms.



Any help would be appreciated, thanks.



Heres what I'm currently doing (a snippet of the client code)



def socketio_task():
"""
The task to run the socket.io client in
"""
sio.connect('http://localhost:8080')
sio.wait()


def gui_task():
"""
The task to display the Pygame GUI with.
"""
global running, image
pygame.init()
screen = pygame.display.set_mode((1280, 720))

while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False

if image is not None:
try:
screen.blit(image, (0, 0))
except pygame.error:
pass
pygame.display.flip()



if __name__ == '__main__':

# TODO: Figure out a way to fix this so that it works on all platforms
sio.start_background_task(socketio_task)
sio.start_background_task(gui_task)









share|improve this question






















  • Quasi-duplicate of stackoverflow.com/questions/54921681/… ?

    – Kingsley
    Mar 7 at 3:12












  • Possible duplicate of pyagme screen not working with multithreading

    – Rabbid76
    Mar 7 at 5:48











  • Did not work when I followed those instructions, I get this on macOS: Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug. The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). @Kingsley

    – dhilln
    Mar 7 at 10:44











  • Note from: developer.apple.com/library/archive/technotes/tn2083/… - "Many Mac OS X frameworks do not work reliably if you call fork but do not call exec. The only exception is the System framework and, even there, the POSIX standard places severe constraints on what you can do between a fork and an exec." Maybe find a later version of SocketIO that doesn't fork(), or use normal python threads. I don't have a Mac, so that's as far as I can answer. Maybe ask a separate question on this error + SocketIO.

    – Kingsley
    Mar 7 at 21:43















0















I'm developing a screen share application and I am using a thread for receiving the data from a socket.io server, and a thread for displaying it. It works perfectly well, as long as I run it under a Linux platform.



I've tried it on my Mac, but after doing some research apparently macOS doesnt allow you to draw to threads other than the main thread, and i need it to work on all platforms.



Any help would be appreciated, thanks.



Heres what I'm currently doing (a snippet of the client code)



def socketio_task():
"""
The task to run the socket.io client in
"""
sio.connect('http://localhost:8080')
sio.wait()


def gui_task():
"""
The task to display the Pygame GUI with.
"""
global running, image
pygame.init()
screen = pygame.display.set_mode((1280, 720))

while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False

if image is not None:
try:
screen.blit(image, (0, 0))
except pygame.error:
pass
pygame.display.flip()



if __name__ == '__main__':

# TODO: Figure out a way to fix this so that it works on all platforms
sio.start_background_task(socketio_task)
sio.start_background_task(gui_task)









share|improve this question






















  • Quasi-duplicate of stackoverflow.com/questions/54921681/… ?

    – Kingsley
    Mar 7 at 3:12












  • Possible duplicate of pyagme screen not working with multithreading

    – Rabbid76
    Mar 7 at 5:48











  • Did not work when I followed those instructions, I get this on macOS: Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug. The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). @Kingsley

    – dhilln
    Mar 7 at 10:44











  • Note from: developer.apple.com/library/archive/technotes/tn2083/… - "Many Mac OS X frameworks do not work reliably if you call fork but do not call exec. The only exception is the System framework and, even there, the POSIX standard places severe constraints on what you can do between a fork and an exec." Maybe find a later version of SocketIO that doesn't fork(), or use normal python threads. I don't have a Mac, so that's as far as I can answer. Maybe ask a separate question on this error + SocketIO.

    – Kingsley
    Mar 7 at 21:43













0












0








0








I'm developing a screen share application and I am using a thread for receiving the data from a socket.io server, and a thread for displaying it. It works perfectly well, as long as I run it under a Linux platform.



I've tried it on my Mac, but after doing some research apparently macOS doesnt allow you to draw to threads other than the main thread, and i need it to work on all platforms.



Any help would be appreciated, thanks.



Heres what I'm currently doing (a snippet of the client code)



def socketio_task():
"""
The task to run the socket.io client in
"""
sio.connect('http://localhost:8080')
sio.wait()


def gui_task():
"""
The task to display the Pygame GUI with.
"""
global running, image
pygame.init()
screen = pygame.display.set_mode((1280, 720))

while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False

if image is not None:
try:
screen.blit(image, (0, 0))
except pygame.error:
pass
pygame.display.flip()



if __name__ == '__main__':

# TODO: Figure out a way to fix this so that it works on all platforms
sio.start_background_task(socketio_task)
sio.start_background_task(gui_task)









share|improve this question














I'm developing a screen share application and I am using a thread for receiving the data from a socket.io server, and a thread for displaying it. It works perfectly well, as long as I run it under a Linux platform.



I've tried it on my Mac, but after doing some research apparently macOS doesnt allow you to draw to threads other than the main thread, and i need it to work on all platforms.



Any help would be appreciated, thanks.



Heres what I'm currently doing (a snippet of the client code)



def socketio_task():
"""
The task to run the socket.io client in
"""
sio.connect('http://localhost:8080')
sio.wait()


def gui_task():
"""
The task to display the Pygame GUI with.
"""
global running, image
pygame.init()
screen = pygame.display.set_mode((1280, 720))

while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False

if image is not None:
try:
screen.blit(image, (0, 0))
except pygame.error:
pass
pygame.display.flip()



if __name__ == '__main__':

# TODO: Figure out a way to fix this so that it works on all platforms
sio.start_background_task(socketio_task)
sio.start_background_task(gui_task)






python multithreading pygame cross-platform python-multithreading






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 7 at 3:01









dhillndhilln

461




461












  • Quasi-duplicate of stackoverflow.com/questions/54921681/… ?

    – Kingsley
    Mar 7 at 3:12












  • Possible duplicate of pyagme screen not working with multithreading

    – Rabbid76
    Mar 7 at 5:48











  • Did not work when I followed those instructions, I get this on macOS: Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug. The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). @Kingsley

    – dhilln
    Mar 7 at 10:44











  • Note from: developer.apple.com/library/archive/technotes/tn2083/… - "Many Mac OS X frameworks do not work reliably if you call fork but do not call exec. The only exception is the System framework and, even there, the POSIX standard places severe constraints on what you can do between a fork and an exec." Maybe find a later version of SocketIO that doesn't fork(), or use normal python threads. I don't have a Mac, so that's as far as I can answer. Maybe ask a separate question on this error + SocketIO.

    – Kingsley
    Mar 7 at 21:43

















  • Quasi-duplicate of stackoverflow.com/questions/54921681/… ?

    – Kingsley
    Mar 7 at 3:12












  • Possible duplicate of pyagme screen not working with multithreading

    – Rabbid76
    Mar 7 at 5:48











  • Did not work when I followed those instructions, I get this on macOS: Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug. The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). @Kingsley

    – dhilln
    Mar 7 at 10:44











  • Note from: developer.apple.com/library/archive/technotes/tn2083/… - "Many Mac OS X frameworks do not work reliably if you call fork but do not call exec. The only exception is the System framework and, even there, the POSIX standard places severe constraints on what you can do between a fork and an exec." Maybe find a later version of SocketIO that doesn't fork(), or use normal python threads. I don't have a Mac, so that's as far as I can answer. Maybe ask a separate question on this error + SocketIO.

    – Kingsley
    Mar 7 at 21:43
















Quasi-duplicate of stackoverflow.com/questions/54921681/… ?

– Kingsley
Mar 7 at 3:12






Quasi-duplicate of stackoverflow.com/questions/54921681/… ?

– Kingsley
Mar 7 at 3:12














Possible duplicate of pyagme screen not working with multithreading

– Rabbid76
Mar 7 at 5:48





Possible duplicate of pyagme screen not working with multithreading

– Rabbid76
Mar 7 at 5:48













Did not work when I followed those instructions, I get this on macOS: Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug. The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). @Kingsley

– dhilln
Mar 7 at 10:44





Did not work when I followed those instructions, I get this on macOS: Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug. The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). @Kingsley

– dhilln
Mar 7 at 10:44













Note from: developer.apple.com/library/archive/technotes/tn2083/… - "Many Mac OS X frameworks do not work reliably if you call fork but do not call exec. The only exception is the System framework and, even there, the POSIX standard places severe constraints on what you can do between a fork and an exec." Maybe find a later version of SocketIO that doesn't fork(), or use normal python threads. I don't have a Mac, so that's as far as I can answer. Maybe ask a separate question on this error + SocketIO.

– Kingsley
Mar 7 at 21:43





Note from: developer.apple.com/library/archive/technotes/tn2083/… - "Many Mac OS X frameworks do not work reliably if you call fork but do not call exec. The only exception is the System framework and, even there, the POSIX standard places severe constraints on what you can do between a fork and an exec." Maybe find a later version of SocketIO that doesn't fork(), or use normal python threads. I don't have a Mac, so that's as far as I can answer. Maybe ask a separate question on this error + SocketIO.

– Kingsley
Mar 7 at 21:43












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55035386%2fhow-to-use-pygame-in-a-seperate-thread-on-linux-mac-and-windows%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55035386%2fhow-to-use-pygame-in-a-seperate-thread-on-linux-mac-and-windows%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved