Skip to content

Commit 4c21fd5

Browse files
committed
do not profile async actions
1 parent d8aa2ce commit 4c21fd5

File tree

2 files changed

+12
-6
lines changed
  • graalpython

2 files changed

+12
-6
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/runtime/ProfileTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,23 @@
4040
*/
4141
package com.oracle.graal.python.test.runtime;
4242

43+
import org.junit.Assert;
4344
import org.junit.Before;
4445

4546
import com.oracle.graal.python.test.PythonTests;
46-
import org.junit.Ignore;
47+
import org.junit.Test;
4748

4849
import java.io.ByteArrayOutputStream;
4950
import java.io.PrintStream;
5051

51-
import static org.junit.Assert.assertEquals;
52-
5352
public class ProfileTests {
5453

5554
@Before
5655
public void ensureBytecode() {
5756
PythonTests.skipOnLegacyASTInterpreter();
5857
}
5958

60-
@Ignore("due to GR-40923")
59+
@Test
6160
public void profileYield() {
6261
String source = "import sys\n" +
6362
"def f(frame, event, arg): print(frame, event, arg)\n" +
@@ -72,7 +71,7 @@ public void profileYield() {
7271
"<module>> return None\n", source);
7372
}
7473

75-
@Ignore("due to GR-40923")
74+
@Test
7675
public void profileException() {
7776
String source = "import sys\n" +
7877
"def f(frame, event, arg): print(frame, event, arg)\n" +
@@ -91,6 +90,6 @@ private static void assertPrints(String expected, String code) {
9190
final PrintStream printStream = new PrintStream(byteArray);
9291
PythonTests.runScript(new String[0], code, printStream, System.err);
9392
String result = byteArray.toString().replaceAll("\r\n", "\n");
94-
assertEquals(expected, result.replaceAll(".*code ", ""));
93+
Assert.assertEquals(expected, result.replaceAll(".*code ", ""));
9594
}
9695
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/AsyncHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ public final void execute(PythonContext context) {
145145
if (!alreadyTracing) {
146146
threadState.tracingStart(PythonContext.TraceEvent.DISABLED);
147147
}
148+
boolean alreadyProfiling = threadState.isProfiling();
149+
if (!alreadyProfiling) {
150+
threadState.profilingStart();
151+
}
148152
debugger.disableStepping();
149153
try {
150154
GenericInvokeNode.getUncached().execute(context.getAsyncHandler().callTarget, args);
@@ -160,6 +164,9 @@ public final void execute(PythonContext context) {
160164
if (!alreadyTracing) {
161165
threadState.tracingStop();
162166
}
167+
if (!alreadyProfiling) {
168+
threadState.profilingStop();
169+
}
163170
}
164171
}
165172
} while (proceed());

0 commit comments

Comments
 (0)