<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.apertium.org/w/index.php?action=history&amp;feed=atom&amp;title=How_to_use_null_flush_in_python</id>
	<title>How to use null flush in python - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.apertium.org/w/index.php?action=history&amp;feed=atom&amp;title=How_to_use_null_flush_in_python"/>
	<link rel="alternate" type="text/html" href="https://wiki.apertium.org/w/index.php?title=How_to_use_null_flush_in_python&amp;action=history"/>
	<updated>2026-05-12T12:26:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.apertium.org/w/index.php?title=How_to_use_null_flush_in_python&amp;diff=74090&amp;oldid=prev</id>
		<title>Firespeaker at 18:12, 15 July 2022</title>
		<link rel="alternate" type="text/html" href="https://wiki.apertium.org/w/index.php?title=How_to_use_null_flush_in_python&amp;diff=74090&amp;oldid=prev"/>
		<updated>2022-07-15T18:12:32Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 18:12, 15 July 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 22:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 22:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;transducer_process.wait()&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;transducer_process.wait()&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;There&#039;s a [https://github.com/apertium/lttoolbox/blob/master/tests/basictest.py more involved example in the lttoolbox tests], which adds handling for when the process hangs.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Firespeaker</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.apertium.org/w/index.php?title=How_to_use_null_flush_in_python&amp;diff=74089&amp;oldid=prev</id>
		<title>Firespeaker at 17:41, 15 July 2022</title>
		<link rel="alternate" type="text/html" href="https://wiki.apertium.org/w/index.php?title=How_to_use_null_flush_in_python&amp;diff=74089&amp;oldid=prev"/>
		<updated>2022-07-15T17:41:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 17:41, 15 July 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 22:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 22:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;transducer_process.wait()&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;transducer_process.wait()&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;[[Category:Documentation]]&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Firespeaker</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.apertium.org/w/index.php?title=How_to_use_null_flush_in_python&amp;diff=74088&amp;oldid=prev</id>
		<title>Firespeaker: Created page with &quot;Many Apertium executables have &quot;null flush&quot; modes (usually with &lt;tt&gt;-z&lt;/tt&gt;), which allows the executable to run once, stay open, accept input, and flush the output only on a...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.apertium.org/w/index.php?title=How_to_use_null_flush_in_python&amp;diff=74088&amp;oldid=prev"/>
		<updated>2022-07-15T17:41:01Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Many Apertium executables have &amp;quot;null flush&amp;quot; modes (usually with &amp;lt;tt&amp;gt;-z&amp;lt;/tt&amp;gt;), which allows the executable to run once, stay open, accept input, and flush the output only on a...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Many Apertium executables have &amp;quot;null flush&amp;quot; modes (usually with &amp;lt;tt&amp;gt;-z&amp;lt;/tt&amp;gt;), which allows the executable to run once, stay open, accept input, and flush the output only on a null character.&lt;br /&gt;
&lt;br /&gt;
Here&amp;#039;s a simple example of how to implement a wrapper in python3 around &amp;lt;code&amp;gt;lt-proc&amp;lt;/code&amp;gt; and a transducer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
from subprocess import Popen, PIPE&lt;br /&gt;
&lt;br /&gt;
things_to_transduce = [&amp;#039;foo&amp;#039;, &amp;#039;bar&amp;#039;, &amp;#039;hargle&amp;#039;, &amp;#039;bargle&amp;#039;]&lt;br /&gt;
&lt;br /&gt;
transducer_process = Popen([&amp;quot;lt-proc&amp;quot;, &amp;quot;-t&amp;quot;, &amp;quot;-z&amp;quot;, &amp;quot;transducer.bin&amp;quot;], stdin=PIPE, stdout=PIPE)&lt;br /&gt;
&lt;br /&gt;
def transduce(inputString):&lt;br /&gt;
	transducer_process.stdin.write(bytes(&amp;#039;{}\n&amp;#039;.format(inputString), &amp;#039;utf-8&amp;#039;))&lt;br /&gt;
	transducer_process.stdin.write(b&amp;#039;\0&amp;#039;)&lt;br /&gt;
	transducer_process.stdin.flush()&lt;br /&gt;
	return repr(transducer_process.stdout.readline().strip(b&amp;#039;\0&amp;#039;).strip(b&amp;#039;\n&amp;#039;).decode())&lt;br /&gt;
&lt;br /&gt;
for thing_to_transduce in things_to_transduce:&lt;br /&gt;
	print(transduce(thing_to_transduce))&lt;br /&gt;
&lt;br /&gt;
transducer_process.stdin.close()&lt;br /&gt;
transducer_process.wait()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Firespeaker</name></author>
		
	</entry>
</feed>