0

I'm trying simple modify an extension example to run firefox,but I get a message prompt :

Firefox is already running,but is no responding. To open a new new window, you must firest close the existing Firefox process, or restart your system.

#!/usr/bin/env python3

import sys
import json
import struct
import subprocess

try:
    # Python 3.x version
    # Read a message from stdin and decode it.
    def getMessage():
        rawLength = sys.stdin.buffer.read(4)
        if len(rawLength) == 0:
            sys.exit(0)
        messageLength = struct.unpack('@I', rawLength)[0]
        message = sys.stdin.buffer.read(messageLength).decode('utf-8')
        return json.loads(message)

    # Encode a message for transmission,
    # given its content.
    def encodeMessage(messageContent):
        encodedContent = json.dumps(messageContent).encode('utf-8')
        encodedLength = struct.pack('@I', len(encodedContent))
        return {'length': encodedLength, 'content': encodedContent}

    # Send an encoded message to stdout
    def sendMessage(encodedMessage):
        sys.stdout.buffer.write(encodedMessage['length'])
        sys.stdout.buffer.write(encodedMessage['content'])
        sys.stdout.buffer.flush()

    while True:
        receivedMessage = getMessage()
        if receivedMessage == "ping":
            run_result=subprocess.run('firefox -P firefox_word ',shell=True,stdout=subprocess.PIPE)
            sendMessage(encodeMessage("pong3"))
except AttributeError:
    pass

My purpose is open a local html file by my extension or native app of my extension.

illiterate
  • 289
  • 2
  • 12

2 Answers2

0

I had a similar issue a while ago, also when I was experimenting with WebExtensions examples. I think the problem is with your Firefox profile. The solution that worked for me was to create a new profile, then (after a day or so) reopen the previous profile. It has been fine since then. I do not know any more details about the problem.

The Mozilla page "Firefox is already running but is not responding" error message - How to fix it describes this solution as well as a number of others (which I tried, but did not have success with).

You can start the Firefox Profile Manager as per the following instructions (see here for complete details):

  1. If Firefox is open, close Firefox:
  2. Press Windows Key + R on the keyboard. A Run dialog will open.
  3. In the Run dialog box, type in: firefox.exe -P Click OK. The Firefox Profile Manager (Choose User Profile) window should open.
  4. Create a new profile, click 'Start Firefox'
  5. To open your previous profile, launch Profile Manager again and select your default profile
0

For me I need work in same profile,now my solution is made a shell script as daemon to read a fifo and my native app of my extension write that fifo when I need run firefox. Note you need run that daemon outside the native app of extension.

illiterate
  • 289
  • 2
  • 12