intellij-blackconnect icon indicating copy to clipboard operation
intellij-blackconnect copied to clipboard

Check if blackd is stared when auto start blackd enabled.

Open kivsiak opened this issue 1 year ago • 5 comments

I'm using both PyCharm and CLion+Rust+Python with blackconnect plugins for native extensions development. When i start second IDE i got error while attempting to bind on address ('127.0.0.1', 45484) cause first IDE already started black daemon.

Also in plugin settings i can see No instances are running at this moment label. That is wrong - the blackd is running and formater is working in both IDE.

I expecting plugin should try to check is blackd listening on 127.0.0.1:45484 when performing availability test.

kivsiak avatar May 03 '23 06:05 kivsiak

Hello!

The reason for this is that the two IDEs do not share any information with each other. One of them runs and tracks blackd daemon instance, while the other has no idea that something is already running and reports it as such.

I agree that No instances are running at this moment is somewhat misleading. It is meant to be read as No instances _started and managed by this IDE instance_ are running.

Currently, I do not see a way to actually share information about started blackd instances between IDEs, but it does make sense not to try and start a new instance if the one at the specified binding address is currently running.

lensvol avatar May 03 '23 17:05 lensvol

I think it's not enough to check only if some blackd is running. Plugin should check that selected binary and running binary have the same versions. And show error if they are differ.

kivsiak avatar May 03 '23 17:05 kivsiak

How about using random ports? Use one blackd process per IDE instance.

pppwaw avatar Sep 29 '23 03:09 pppwaw

That is doable but introduces additional problems with the need to retry if a randomly selected port is already taken. I'll look into this.

lensvol avatar Oct 15 '23 10:10 lensvol

This is my only issue with the plugin - and obviously not a huge issue.

We could read the X-Black-Version header, and compare to the expected version - but honestly this seems like an edge case (where one IDE instance has a different version of blackd configured, and started, and another IDE is started) far enough away that we shouldn't let perfect be the enemy of good.

IMHO, the plugin should empty POST to see if it's the black server on that port - if it is, great. If it isn't, display an error. This would avoid printing an stack trace when another IDE starts a blackd instance.

Mattwmaster58 avatar Aug 28 '24 03:08 Mattwmaster58