question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

obs-websocket + APScheduler

See original GitHub issue

Hello , I am just working on a project using both libraries obs-websocket + APScheduler . I used obs-websocket in conjunction with APSscheduler in order to schedule some jobs. The jobs update some scenes and objects inside the scene.

I used atomical function like this:

def createOBSWS():
    host = settings.WS_HOST
    port = settings.WS_PORT
    password = settings.WS_PASS
    websocket = obsws(host, port, password)
    return websocket

....
....

   if (websocket is None):
        websocket = createOBSWS()
        websocket.connect()
        websocket.call(requests.SetCurrentScene(sceneName))
        websocket.disconnect() 

In both linux and win box , I am getting this kind of errors .

WIN .... venv\lib\site-packages\websocket\_socket.py", line 139, in _send return sock.send(data) OSError: [WinError 10038] Tentativo di operazione su un elemento diverso dal socket

DEB lib/python3.5/site-packages/websocket/_socket.py", line 139, in _send return sock.send(data) OSError: [Errno 9] Bad file descriptor

They are both related. I supposed that I call the disconnect before sending the command to the obs-websocket-server , but I followed your examples. I tried your last release 0.5, python 3.5 (Debian), python 3.6 (Win)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Elektordicommented, Jan 5, 2020

Oh, thanks for the traceback, I can see the problem is on the receiving thread!

I think the problem is threads being handled differently because of APScheduler… The receiving is not interrupted correctly… Could you try the branch bugfix-32 I just pushed? It should ignore OS exceptions during socket disconnection.

1reaction
Elektordicommented, Jan 5, 2020
[elektordi@gg7 ~]$ pip3 freeze |grep socket
obs-websocket-py==0.5
requests-unixsocket==0.1.5
websocket-client==0.57.0

But I also work with Django on others projets, and I had many problems with a scheduler on one. I finally discover it came from Django multi-thread architecture, my jobs were started multiple times at the same moment. I finally fixed using this “if”:

def init():
    if os.environ.get('RUN_MAIN', None) != "true":
        return

    scheduler = BackgroundScheduler()
    scheduler.add_job(job_daily_report, 'cron', hour=7, minute=0)
    scheduler.start()
    logger.info('Scheduler has been started!')

init() was called by ready(self) in my AppConfig (file apps.py) Maybe it can help you…

Read more comments on GitHub >

github_iconTop Results From Across the Web

obs-websocket - Remote-control OBS Studio using WebSockets
A WebSocket RPC API for OBS Studio. The WebSocket server runs on port 4455. See here for client software and libraries that support...
Read more >
Elektordi/obs-websocket-py: Python library to ... - GitHub
Python library to communicate with an obs-websocket server (for OBS Studio) - GitHub - Elektordi/obs-websocket-py: Python library to communicate with an ...
Read more >
OBS Websockets - FMS Manual - Read the Docs
OBS Websockets / OBS Integration allows you to control your video feed (for use on a webstream, or potentially on a scoreboard at...
Read more >
Newest 'scheduler' Questions - Page 2 - Stack Overflow
hello i have my python code: from apscheduler.schedulers.background import ... and reacting to OBS Studio (live-streaming software), using obs-websocket.
Read more >
Search Results for "%s" - SlackBuilds.org
APScheduler, Python, 3.4.0, 15.0 ... obexpushd, Network, 0.8, 13.0. obs-studio, Multimedia, 28.0.2, 15.0 ... python2-websocket-client, Python, 0.59.0, 15.0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found