Giter Club home page Giter Club logo

Comments (16)

Cacodaimon avatar Cacodaimon commented on September 14, 2024

I have currently no idea how to detect a plugin reload…

from ghosttext.

fregante avatar fregante commented on September 14, 2024

You're right, it's a strange request, can you ask on ST's forum?

from ghosttext.

Cacodaimon avatar Cacodaimon commented on September 14, 2024

Yeah I gonna register me there for asking…

from ghosttext.

fregante avatar fregante commented on September 14, 2024

Found the solution!

If a plugin defines a module level function plugin_loaded(), this will be called when the API is ready to use. Plugins may also define plugin_unloaded(), to get notified just before the plugin is unloaded.
https://www.sublimetext.com/docs/3/api_reference.html

from ghosttext.

Cacodaimon avatar Cacodaimon commented on September 14, 2024

This is great! I search this API doc several times and didn't see this 😊

from ghosttext.

Cacodaimon avatar Cacodaimon commented on September 14, 2024

Can you check if it works on OS X, too and reopen it if needed.

from ghosttext.

fregante avatar fregante commented on September 14, 2024

ST start

GhostTest is starting now…
Setting on request handler
HTTP Start
Emmet: No need to update PyV8
no command for selector: noop:
found 21 files for base name Main.sublime-menu
Package Control: Skipping automatic upgrade, last run at 2014-07-12 02:33:05, next run at 2014-07-12 03:33:05 or after
Writing file /Users/bfred/Web/Gitbase/GhostTextForSublimeText/GhostText.py with encoding UTF-8 (atomic)

GhostText.py file change

reloading plugin GhostText.GhostText
GhostTest is stopping now…
<HttpStatusServerThread(Thread-2, started 4475600896)>
HTTP Stop
Skipped OSError
GhostTest is starting now…
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 115, in reload_plugin
    m.plugin_loaded()
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 173, in plugin_loaded
    GhostTextGlobals.http_status_server_thread = HttpStatusServerThread(settings)
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 68, in __init__
    self._server = HttpServer('localhost', server_port)
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/Http/HttpServer.py", line 13, in __init__
    self._socket.bind((host, port))
OSError: [Errno 48] Address already in use

Not working. I tried restarting a couple times but the issue is still there, probably because of that Skipped OSError

from ghosttext.

fregante avatar fregante commented on September 14, 2024

I don't know what's up… now it's working.

from ghosttext.

fregante avatar fregante commented on September 14, 2024

I see what happened. It considers FocusSublimeWindow.py as a plugin on its own, so editing that file doesn't actually reload the whole GT. Editing GhostText.py on the other hand produces that error above

from ghosttext.

Cacodaimon avatar Cacodaimon commented on September 14, 2024

Yes all .py files on the plugin root gets interpreted as a single plugin, FocusSublimeWindow is a mini plugin…

I have added a traceback where the Skipped OSError message occurs, can you give me the error message since it seems to be a OS X specific error?

from ghosttext.

fregante avatar fregante commented on September 14, 2024

Here you go

reloading plugin GhostText.GhostText
GhostTest is stopping now…
<HttpStatusServerThread(Thread-1, started 4564324352)>
HTTP Stop
Skipped OSError
[Errno 57] Socket is not connected
Traceback (most recent call last):
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/Http/HttpServer.py", line 43, in stop
    self._socket.shutdown(socket.SHUT_RDWR)
OSError: [Errno 57] Socket is not connected

GhostTest is starting now…
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 115, in reload_plugin
    m.plugin_loaded()
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 173, in plugin_loaded
    GhostTextGlobals.http_status_server_thread = HttpStatusServerThread(settings)
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 68, in __init__
    self._server = HttpServer('localhost', server_port)
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/Http/HttpServer.py", line 14, in __init__
    self._socket.bind((host, port))
OSError: [Errno 48] Address already in use

from ghosttext.

Cacodaimon avatar Cacodaimon commented on September 14, 2024

The Socket is not connected error should be catched now…

from ghosttext.

fregante avatar fregante commented on September 14, 2024

I verified that the plugin is actually reloading correctly and the new server code is used: I did so by using a print(2) in onMessage.on_message

I see these issues though:

Writing file /Users/bfred/Web/Gitbase/GhostText-for-SublimeText/GhostText.py with encoding UTF-8 (atomic)
reloading plugin GhostText.GhostText
GhostTest is stopping now…
<HttpStatusServerThread(Thread-2, started 4461576192)>
HTTP Stop
[Errno 57] Socket is not connected
Traceback (most recent call last):
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/Http/HttpServer.py", line 50, in stop
    self._socket.shutdown(socket.SHUT_RDWR)
OSError: [Errno 57] Socket is not connected

HTTP Stopped
GhostTest is starting now…
Setting on request handler
Exception in thread Thread-2:
Traceback (most recent call last):
  File "X/threading.py", line 639, in _bootstrap_inner
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 77, in run
    raise e
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/GhostText.py", line 74, in run
    self._server.start()
  File "/Users/bfred/Library/Application Support/Sublime Text 3/Packages/GhostText/Http/HttpServer.py", line 27, in start
    self._conn, self._address = self._socket.accept()
  File "X/socket.py", line 135, in accept
ConnectionAbortedError: [Errno 53] Software caused connection abort

HTTP Start

from ghosttext.

Cacodaimon avatar Cacodaimon commented on September 14, 2024

Cool thanks now I know what went wrong, a little try catch around the socket's accept should fix it.

from ghosttext.

fregante avatar fregante commented on September 14, 2024

Try/catch is a quick way to hide the errors but the problems will still be there :D

from ghosttext.

Cacodaimon avatar Cacodaimon commented on September 14, 2024

In this case there is no other way to solve it, the accept blocks the thread until a message arrives so there is no way to stop the accept itself. When the connection gets closed the accept fires the exception because it has been closed…

from ghosttext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.