summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/esp32/mphalport.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ports/esp32/mphalport.c b/ports/esp32/mphalport.c
index aa79c878e..7992c8ded 100644
--- a/ports/esp32/mphalport.c
+++ b/ports/esp32/mphalport.c
@@ -61,11 +61,17 @@ void mp_hal_stdout_tx_str(const char *str) {
}
void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
- MP_THREAD_GIL_EXIT();
+ // Only release the GIL if many characters are being sent
+ bool release_gil = len > 20;
+ if (release_gil) {
+ MP_THREAD_GIL_EXIT();
+ }
for (uint32_t i = 0; i < len; ++i) {
uart_tx_one_char(str[i]);
}
- MP_THREAD_GIL_ENTER();
+ if (release_gil) {
+ MP_THREAD_GIL_ENTER();
+ }
mp_uos_dupterm_tx_strn(str, len);
}