koxudaxi / ruff-pycharm-plugin

PyCharm plugin for ruff. This plugin provides reformat code using ruff.
MIT License
222 stars 10 forks source link

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action only (see Application.runReadAction()); see https://jb.gg/ij-platform-threading for details #493

Closed andrewkoltsov closed 2 months ago

andrewkoltsov commented 2 months ago

Build #PY-242.20224.347, built on August 9, 2024 Runtime version: 21.0.3+13-b509.4 x86_64 (JCEF 122.1.9) VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Toolkit: sun.lwawt.macosx.LWCToolkit macOS 14.6.1 GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation Memory: 2048M Cores: 12 Metal Rendering is ON Registry: ide.experimental.ui=true Non-Bundled Plugins: name.kropp.intellij.makefile (242.20224.155) com.intellij.ml.llm (242.20224.419) com.koxudaxi.ruff (0.0.35) org.sonarlint.idea (10.8.1.79205) com.github.copilot (1.5.20.6554)

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action only (see Application.runReadAction()); see https://jb.gg/ij-platform-threading for details Current thread: Thread[#23203,ApplicationImpl pooled thread 3494,4,main] 494205886 (EventQueue.isDispatchThread()=false) SystemEventQueueThread: Thread[#59,AWT-EventQueue-0,6,main] 1177366894 at com.intellij.util.concurrency.ThreadingAssertions.createThreadAccessException(ThreadingAssertions.java:177) at com.intellij.util.concurrency.ThreadingAssertions.softAssertReadAccess(ThreadingAssertions.java:129) at com.intellij.openapi.fileEditor.FileDocumentManager.getDocument(FileDocumentManager.java:60) at com.intellij.psi.AbstractFileViewProvider.getDocument(AbstractFileViewProvider.java:170) at com.intellij.psi.AbstractFileViewProvider$VirtualFileContent.getText(AbstractFileViewProvider.java:446) at com.intellij.psi.AbstractFileViewProvider.getContents(AbstractFileViewProvider.java:151) at com.intellij.psi.impl.source.PsiFileImpl.getText(PsiFileImpl.java:312) at com.koxudaxi.ruff.SourceFile$text$2.invoke(Ruff.kt:300) at com.koxudaxi.ruff.SourceFile$text$2.invoke(Ruff.kt:297) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at com.koxudaxi.ruff.SourceFile.getText(Ruff.kt:297) at com.koxudaxi.ruff.SourceFile.getAsStdin(Ruff.kt:311) at com.koxudaxi.ruff.RuffKt.generateCommandArgs(Ruff.kt:336) at com.koxudaxi.ruff.RuffKt.runRuff(Ruff.kt:321) at com.koxudaxi.ruff.RuffApplyService$apply$$inlined$runReadActionOnPooledThread$default$1$1.call(Ruff.kt:551) at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport$executeOnPooledThread$2.call(AnyThreadWriteThreadingSupport.kt:162) at com.intellij.util.concurrency.ContextCallable.call(ContextCallable.java:32) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732) at java.base/java.security.AccessController.doPrivileged(AccessController.java:400) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732) at java.base/java.lang.Thread.run(Thread.java:1583)

maksim-m commented 1 week ago

@koxudaxi I still face this kind of error with plugin version 0.0.42:

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action only (see Application.runReadAction()); If you access or modify model on EDT consider wrapping your code in WriteIntentReadAction  or ReadAction; see https://jb.gg/ij-platform-threading for details
Current thread: Thread[#645,ApplicationImpl pooled thread 26,4,main] 1876073418 (EventQueue.isDispatchThread()=false)
SystemEventQueueThread: Thread[#55,AWT-EventQueue-0,6,main] 337861022
    at com.intellij.util.concurrency.ThreadingAssertions.createThreadAccessException(ThreadingAssertions.java:218)
    at com.intellij.util.concurrency.ThreadingAssertions.softAssertReadAccess(ThreadingAssertions.java:155)
    at com.intellij.openapi.fileEditor.FileDocumentManager.getDocument(FileDocumentManager.java:60)
    at com.intellij.psi.AbstractFileViewProvider.getDocument(AbstractFileViewProvider.java:170)
    at com.intellij.psi.AbstractFileViewProvider$VirtualFileContent.getText(AbstractFileViewProvider.java:446)
    at com.intellij.psi.AbstractFileViewProvider.getContents(AbstractFileViewProvider.java:151)
    at com.intellij.psi.impl.source.PsiFileImpl.getText(PsiFileImpl.java:327)
    at com.koxudaxi.ruff.SourceFile$text$2.invoke(Ruff.kt:362)
    at com.koxudaxi.ruff.SourceFile$text$2.invoke(Ruff.kt:359)
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    at com.koxudaxi.ruff.SourceFile.getText(Ruff.kt:359)
    at com.koxudaxi.ruff.SourceFile.getAsStdin(Ruff.kt:373)
    at com.koxudaxi.ruff.RuffKt.generateCommandArgs(Ruff.kt:398)
    at com.koxudaxi.ruff.RuffKt.runRuff(Ruff.kt:383)
    at com.koxudaxi.ruff.RuffApplyService$apply$$inlined$runReadActionOnPooledThread$default$1$1.call(Ruff.kt:612)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport$executeOnPooledThread$2.call(AnyThreadWriteThreadingSupport.kt:195)
    at com.intellij.util.concurrency.ContextCallable.lambda$call$1(ContextCallable.java:74)
    at com.intellij.util.concurrency.ContextCallable.call(ContextCallable.java:83)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:101)
    at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:101)
    at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:107)
    at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:101)
    at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732)
    at java.base/java.lang.Thread.run(Thread.java:1583)
com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Read access is allowed from inside read-action only (see Application.runReadAction()); If you access or modify model on EDT consider wrapping your code in WriteIntentReadAction  or ReadAction; see https://jb.gg/ij-platform-threading for details
Current thread: Thread[#645,ApplicationImpl pooled thread 26,4,main] 1876073418 (EventQueue.isDispatchThread()=false)
SystemEventQueueThread: Thread[#55,AWT-EventQueue-0,6,main] 337861022
    at com.intellij.util.concurrency.ThreadingAssertions.createThreadAccessException(ThreadingAssertions.java:218)
    at com.intellij.util.concurrency.ThreadingAssertions.softAssertReadAccess(ThreadingAssertions.java:155)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerBase.getDocument(FileDocumentManagerBase.java:50)
    at com.intellij.openapi.fileEditor.FileDocumentManager.getDocument(FileDocumentManager.java:61)
    at com.intellij.psi.AbstractFileViewProvider.getDocument(AbstractFileViewProvider.java:170)
    at com.intellij.psi.AbstractFileViewProvider$VirtualFileContent.getText(AbstractFileViewProvider.java:446)
    at com.intellij.psi.AbstractFileViewProvider.getContents(AbstractFileViewProvider.java:151)
    at com.intellij.psi.impl.source.PsiFileImpl.getText(PsiFileImpl.java:327)
    at com.koxudaxi.ruff.SourceFile$text$2.invoke(Ruff.kt:362)
    at com.koxudaxi.ruff.SourceFile$text$2.invoke(Ruff.kt:359)
    at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    at com.koxudaxi.ruff.SourceFile.getText(Ruff.kt:359)
    at com.koxudaxi.ruff.SourceFile.getAsStdin(Ruff.kt:373)
    at com.koxudaxi.ruff.RuffKt.generateCommandArgs(Ruff.kt:398)
    at com.koxudaxi.ruff.RuffKt.runRuff(Ruff.kt:383)
    at com.koxudaxi.ruff.RuffApplyService$apply$$inlined$runReadActionOnPooledThread$default$1$1.call(Ruff.kt:612)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport$executeOnPooledThread$2.call(AnyThreadWriteThreadingSupport.kt:195)
    at com.intellij.util.concurrency.ContextCallable.lambda$call$1(ContextCallable.java:74)
    at com.intellij.util.concurrency.ContextCallable.call(ContextCallable.java:83)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:101)
    at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:101)
    at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:107)
    at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:101)
    at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732)
    at java.base/java.lang.Thread.run(Thread.java:1583)

PyCharm 2024.3 (Community Edition) Build #PC-243.21565.199, built on November 13, 2024 Runtime version: 21.0.5+8-b631.16 aarch64 (JCEF 122.1.9) VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Toolkit: sun.lwawt.macosx.LWCToolkit macOS 14.7.1 GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation Memory: 4096M Cores: 11 Metal Rendering is ON Registry: ide.experimental.ui=true i18n.locale= terminal.new.ui=true Non-Bundled Plugins: name.kropp.intellij.makefile (243.21565.122) ru.adelf.idea.dotenv (2024.3) com.koxudaxi.ruff (0.0.42) org.jetbrains.plugins.gitlab (243.21565.204)